#include <iostream>
#include <pthread.h>
#include <unistd.h>

//新线程
void* start_routine(void* args)
{
    char* message = (char*)args;
    while(true)
    {
        std::cout << message << " run" << " pid=" << getpid() << std::endl;
        sleep(1);
    }
}
//主线程
int main()
{
    pthread_t thread;
    pthread_create(&thread, nullptr, start_routine, (void*)"new thread");

    while(true)
    {
        std::cout << "main thread run" << " pid=" << getpid() << std::endl;
        sleep(1);
    }

    return 0;
}
